
using WorkV5APIS.Common;
using WorkV5APIS.Models;
using WorkV5APIS.Models.NoDBModel;

string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";
var builder = WebApplication.CreateBuilder(args);


builder.Services.AddCors(options =>
{
    options.AddPolicy(name: MyAllowSpecificOrigins,
      builder =>
      {
          builder.WithOrigins("http://localhost:8080", "*")

                           .AllowAnyHeader()
                           .AllowAnyMethod();
      });
});


IConfiguration configuration = new ConfigurationBuilder()
                            .AddJsonFile("appsettings.json")
                            .Build();


builder.Services.AddSingleton(new AppHelper(configuration));


builder.Services.AddMvc();


var app = builder.Build();


linkDB.CodeFirst();
linkDB.DefaultData();

app.UseCors(MyAllowSpecificOrigins);

app.UseStaticFiles();

app.UseRouting();



app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");


app.Run();
